home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver25.zip / SOURCE.ZIP / Saverdlg.cpp < prev    next >
C/C++ Source or Header  |  1997-07-25  |  5KB  |  190 lines

  1. // Saverdlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Saver.h"
  6. #include "drawwnd.h"
  7. #include "Saverdlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16.  
  17. class CAboutDlg : public CDialog
  18. {
  19. public:
  20.     CAboutDlg();
  21.  
  22. // Dialog Data
  23.     //{{AFX_DATA(CAboutDlg)
  24.     enum { IDD = IDD_ABOUTBOX };
  25.     //}}AFX_DATA
  26.  
  27. // Implementation
  28. protected:
  29.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  30.     //{{AFX_MSG(CAboutDlg)
  31.     virtual BOOL OnInitDialog();
  32.     //}}AFX_MSG
  33.     DECLARE_MESSAGE_MAP()
  34. };
  35.  
  36. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  37. {
  38.     //{{AFX_DATA_INIT(CAboutDlg)
  39.     //}}AFX_DATA_INIT
  40. }
  41.  
  42. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CDialog::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CAboutDlg)
  46.     //}}AFX_DATA_MAP
  47. }
  48.  
  49. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  50.     //{{AFX_MSG_MAP(CAboutDlg)
  51.         // No message handlers
  52.     //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CAboutDlg message handlers
  57.  
  58. BOOL CAboutDlg::OnInitDialog()
  59. {
  60.     CDialog::OnInitDialog();
  61.     CenterWindow();
  62.     
  63.     // TODO: Add extra about dlg initialization here
  64.     
  65.     return TRUE;  // return TRUE  unless you set the focus to a control
  66. }
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CSaverDlg dialog
  70.  
  71. CSaverDlg::CSaverDlg(CWnd* pParent /*=NULL*/)
  72.     : CDialog(CSaverDlg::IDD, pParent)//, m_wndPreview(FALSE)
  73. {
  74.     //{{AFX_DATA_INIT(CSaverDlg)
  75.     m_nName = _T("");
  76.     m_musicDisable = FALSE;
  77.     //}}AFX_DATA_INIT
  78.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  79.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  80. }
  81.  
  82. void CSaverDlg::DoDataExchange(CDataExchange* pDX)
  83. {
  84.     CDialog::DoDataExchange(pDX);
  85.     //{{AFX_DATA_MAP(CSaverDlg)
  86.     DDX_Control(pDX, IDC_EDIT1, m_fileName);
  87.     DDX_Text(pDX, IDC_EDIT1, m_nName);
  88.     DDX_Check(pDX, IDC_CHECK1, m_musicDisable);
  89.     //}}AFX_DATA_MAP
  90. }
  91.  
  92. BEGIN_MESSAGE_MAP(CSaverDlg, CDialog)
  93.     //{{AFX_MSG_MAP(CSaverDlg)
  94.     ON_WM_SYSCOMMAND()
  95.     ON_WM_PAINT()
  96.     ON_WM_QUERYDRAGICON()
  97.     ON_BN_CLICKED(IDC_BUTTON_FILE, OnButtonFile)
  98.     //}}AFX_MSG_MAP
  99. END_MESSAGE_MAP()
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CSaverDlg message handlers
  103.  
  104. BOOL CSaverDlg::OnInitDialog()
  105. {
  106.     CDialog::OnInitDialog();
  107.     CenterWindow();
  108. /*
  109.     // Add "About..." menu item to system menu.
  110.  
  111.     // IDM_ABOUTBOX must be in the system command range.
  112.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  113.     ASSERT(IDM_ABOUTBOX < 0xF000);
  114.  
  115.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  116.     CString strAboutMenu;
  117.     strAboutMenu.LoadString(IDS_ABOUTBOX);
  118.     if (!strAboutMenu.IsEmpty())
  119.     {
  120.         pSysMenu->AppendMenu(MF_SEPARATOR);
  121.         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  122.     }
  123.     
  124.     // TODO: Add extra initialization here
  125. */    
  126.     return TRUE;  // return TRUE  unless you set the focus to a control
  127. }
  128.  
  129. void CSaverDlg::OnSysCommand(UINT nID, LPARAM lParam)
  130. {
  131.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  132.     {
  133.         CAboutDlg dlgAbout;
  134.         dlgAbout.DoModal();
  135.     }
  136.     else
  137.     {
  138.         CDialog::OnSysCommand(nID, lParam);
  139.     }
  140. }
  141.  
  142. // If you add a minimize button to your dialog, you will need the code below
  143. //  to draw the icon.  For MFC applications using the document/view model,
  144. //  this is automatically done for you by the framework.
  145.  
  146. void CSaverDlg::OnPaint() 
  147. {
  148.     if (IsIconic())
  149.     {
  150.         CPaintDC dc(this); // device context for painting
  151.  
  152.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  153.  
  154.         // Center icon in client rectangle
  155.         int cxIcon = GetSystemMetrics(SM_CXICON);
  156.         int cyIcon = GetSystemMetrics(SM_CYICON);
  157.         CRect rect;
  158.         GetClientRect(&rect);
  159.         int x = (rect.Width() - cxIcon + 1) / 2;
  160.         int y = (rect.Height() - cyIcon + 1) / 2;
  161.  
  162.         // Draw the icon
  163.         dc.DrawIcon(x, y, m_hIcon);
  164.     }
  165.     else
  166.     {
  167.         CDialog::OnPaint();
  168.     }
  169. }
  170.  
  171. // The system calls this to obtain the cursor to display while the user drags
  172. //  the minimized window.
  173. HCURSOR CSaverDlg::OnQueryDragIcon()
  174. {
  175.     return (HCURSOR) m_hIcon;
  176. }
  177.  
  178. void CSaverDlg::OnButtonFile()
  179. {
  180.     static char BASED_CODE szFilter[] = "FastTracker Files (*.xm)|*.xm|ScreamTracker Files (*.s3m)|*.s3m|NoiseTracker Files (*.mod)|*.mod|All Files (*.*)|*.*||";
  181.     char temps[500+1];
  182.     m_fileName.GetWindowText(temps,500);
  183.     CFileDialog dlg(TRUE,NULL,temps,NULL,szFilter);
  184.     if (dlg.DoModal() == IDOK)
  185.     {
  186.         m_fileName.SetWindowText(dlg.GetPathName());
  187.     }
  188. }
  189.  
  190.